<?php

use App\Helpers\XLog;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Routing\Router;
use Modules\Admin\Services\PermissionService;

class RefreshPermissionByRouteTable extends Migration
{
    /**
     *
     * 功能说明：刷新控制台的权限
     *
     * @return void
     */
    public function up()
    {
        // 获得路由的实例
        $router = app('Illuminate\Routing\Router');

        /* 1、先删除和 控制台相关是控制台 */
        PermissionService::getInstance()->delPermission('all', '控制台');
        /* 2、刷新控制台的权限 */
        PermissionService::getInstance()->refreshPermissionByRoute($router, 'admin', '控制台');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        return null;
    }
}
